<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>cpp_redis: includes/cpp_redis/network/tcp_client.hpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="cpp_redis_logo.jpg"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">cpp_redis
   &#160;<span id="projectnumber">4.0.0</span>
   </div>
   <div id="projectbrief">cpp_redis is a C++11 Asynchronous Multi-Platform Lightweight Redis Client, with support for synchronous operations and pipelining.</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_09e761304027c904456130627fd4dcf5.html">includes</a></li><li class="navelem"><a class="el" href="dir_aabee9b2b90be9a3c8dcec590ad04d13.html">cpp_redis</a></li><li class="navelem"><a class="el" href="dir_385d11d1b9f28fad9d9928b9e15978bd.html">network</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">tcp_client.hpp</div>  </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="comment">// MIT License</span></div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="comment">//</span></div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="comment">// Copyright (c) 2016-2017 Simon Ninon &lt;simon.ninon@gmail.com&gt;</span></div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="comment">//</span></div><div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="comment">// Permission is hereby granted, free of charge, to any person obtaining a copy</span></div><div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="comment">// of this software and associated documentation files (the &quot;Software&quot;), to deal</span></div><div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="comment">// in the Software without restriction, including without limitation the rights</span></div><div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="comment">// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell</span></div><div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;<span class="comment">// copies of the Software, and to permit persons to whom the Software is</span></div><div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="comment">// furnished to do so, subject to the following conditions:</span></div><div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<span class="comment">//</span></div><div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="comment">// The above copyright notice and this permission notice shall be included in all</span></div><div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="comment">// copies or substantial portions of the Software.</span></div><div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;<span class="comment">//</span></div><div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;<span class="comment">// THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR</span></div><div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;<span class="comment">// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,</span></div><div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;<span class="comment">// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE</span></div><div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;<span class="comment">// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER</span></div><div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;<span class="comment">// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,</span></div><div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;<span class="comment">// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span></div><div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;<span class="comment">// SOFTWARE.</span></div><div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;</div><div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;<span class="preprocessor">#pragma once</span></div><div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;</div><div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;<span class="preprocessor">#include &lt;cpp_redis/misc/error.hpp&gt;</span></div><div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;<span class="preprocessor">#include &lt;cpp_redis/network/tcp_client_iface.hpp&gt;</span></div><div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;</div><div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;<span class="preprocessor">#include &lt;tacopie/tacopie&gt;</span></div><div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;</div><div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;<span class="keyword">namespace </span><a class="code" href="namespacecpp__redis.html">cpp_redis</a> {</div><div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;</div><div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;<span class="keyword">namespace </span>network {</div><div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;</div><div class="line"><a name="l00037"></a><span class="lineno"><a class="line" href="classcpp__redis_1_1network_1_1tcp__client.html">   37</a></span>&#160;<span class="keyword">class </span><a class="code" href="classcpp__redis_1_1network_1_1tcp__client.html">tcp_client</a> : <span class="keyword">public</span> <a class="code" href="classcpp__redis_1_1network_1_1tcp__client__iface.html">tcp_client_iface</a> {</div><div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;<span class="keyword">public</span>:</div><div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;  <a class="code" href="classcpp__redis_1_1network_1_1tcp__client.html#a8cbad07ca636e9d60dafc0e5cac8106d">tcp_client</a>(<span class="keywordtype">void</span>) = <span class="keywordflow">default</span>;</div><div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;  <a class="code" href="classcpp__redis_1_1network_1_1tcp__client.html#af859036bbc7e5ec9149c1410a1a66f09">~tcp_client</a>(<span class="keywordtype">void</span>) = <span class="keywordflow">default</span>;</div><div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;</div><div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;<span class="keyword">public</span>:</div><div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;  <span class="keywordtype">void</span> <a class="code" href="classcpp__redis_1_1network_1_1tcp__client.html#a5808c0569980d83479f755ac55a12dfb">connect</a>(<span class="keyword">const</span> std::string&amp; addr, std::uint32_t port, std::uint32_t timeout_msecs);</div><div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;</div><div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;  <span class="keywordtype">void</span> <a class="code" href="classcpp__redis_1_1network_1_1tcp__client.html#a88f49c4e32d59855a62296fb74136a44">disconnect</a>(<span class="keywordtype">bool</span> wait_for_removal = <span class="keyword">false</span>);</div><div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;</div><div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;  <span class="keywordtype">bool</span> <a class="code" href="classcpp__redis_1_1network_1_1tcp__client.html#a0a636ca6bd59425bf22416a1c7694f65">is_connected</a>(<span class="keywordtype">void</span>) <span class="keyword">const</span>;</div><div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;</div><div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;  <span class="keywordtype">void</span> <a class="code" href="classcpp__redis_1_1network_1_1tcp__client.html#aa56fc49540d67c5c05b3dda3aaff8a0f">set_nb_workers</a>(std::size_t nb_threads);</div><div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;</div><div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;<span class="keyword">public</span>:</div><div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;  <span class="keywordtype">void</span> <a class="code" href="classcpp__redis_1_1network_1_1tcp__client.html#a5eed4225fcd01e3108580d863c94c2cc">async_read</a>(<a class="code" href="structcpp__redis_1_1network_1_1tcp__client__iface_1_1read__request.html">read_request</a>&amp; request);</div><div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;</div><div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;  <span class="keywordtype">void</span> <a class="code" href="classcpp__redis_1_1network_1_1tcp__client.html#a6d15785b71776cd85426c9634cb446f0">async_write</a>(<a class="code" href="structcpp__redis_1_1network_1_1tcp__client__iface_1_1write__request.html">write_request</a>&amp; request);</div><div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160;</div><div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;<span class="keyword">public</span>:</div><div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;  <span class="keywordtype">void</span> <a class="code" href="classcpp__redis_1_1network_1_1tcp__client.html#a24ccdf6dc467aac13cb832a395adb38d">set_on_disconnection_handler</a>(<span class="keyword">const</span> <a class="code" href="classcpp__redis_1_1network_1_1tcp__client__iface.html#a9a7d5942205db8be03da581a848b8ec0">disconnection_handler_t</a>&amp; disconnection_handler);</div><div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;</div><div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;<span class="keyword">private</span>:</div><div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;  tacopie::tcp_client m_client;</div><div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;};</div><div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;</div><div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;<span class="keywordtype">void</span> set_default_nb_workers(std::size_t nb_threads);</div><div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160;</div><div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;} <span class="comment">// namespace network</span></div><div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160;</div><div class="line"><a name="l00112"></a><span class="lineno">  112</span>&#160;} <span class="comment">// namespace cpp_redis</span></div><div class="ttc" id="classcpp__redis_1_1network_1_1tcp__client_html_af859036bbc7e5ec9149c1410a1a66f09"><div class="ttname"><a href="classcpp__redis_1_1network_1_1tcp__client.html#af859036bbc7e5ec9149c1410a1a66f09">cpp_redis::network::tcp_client::~tcp_client</a></div><div class="ttdeci">~tcp_client(void)=default</div><div class="ttdoc">dtor </div></div>
<div class="ttc" id="classcpp__redis_1_1network_1_1tcp__client_html_a24ccdf6dc467aac13cb832a395adb38d"><div class="ttname"><a href="classcpp__redis_1_1network_1_1tcp__client.html#a24ccdf6dc467aac13cb832a395adb38d">cpp_redis::network::tcp_client::set_on_disconnection_handler</a></div><div class="ttdeci">void set_on_disconnection_handler(const disconnection_handler_t &amp;disconnection_handler)</div></div>
<div class="ttc" id="classcpp__redis_1_1network_1_1tcp__client_html_a0a636ca6bd59425bf22416a1c7694f65"><div class="ttname"><a href="classcpp__redis_1_1network_1_1tcp__client.html#a0a636ca6bd59425bf22416a1c7694f65">cpp_redis::network::tcp_client::is_connected</a></div><div class="ttdeci">bool is_connected(void) const</div></div>
<div class="ttc" id="classcpp__redis_1_1network_1_1tcp__client_html_a88f49c4e32d59855a62296fb74136a44"><div class="ttname"><a href="classcpp__redis_1_1network_1_1tcp__client.html#a88f49c4e32d59855a62296fb74136a44">cpp_redis::network::tcp_client::disconnect</a></div><div class="ttdeci">void disconnect(bool wait_for_removal=false)</div></div>
<div class="ttc" id="classcpp__redis_1_1network_1_1tcp__client_html_a5eed4225fcd01e3108580d863c94c2cc"><div class="ttname"><a href="classcpp__redis_1_1network_1_1tcp__client.html#a5eed4225fcd01e3108580d863c94c2cc">cpp_redis::network::tcp_client::async_read</a></div><div class="ttdeci">void async_read(read_request &amp;request)</div></div>
<div class="ttc" id="structcpp__redis_1_1network_1_1tcp__client__iface_1_1read__request_html"><div class="ttname"><a href="structcpp__redis_1_1network_1_1tcp__client__iface_1_1read__request.html">cpp_redis::network::tcp_client_iface::read_request</a></div><div class="ttdef"><b>Definition:</b> tcp_client_iface.hpp:114</div></div>
<div class="ttc" id="classcpp__redis_1_1network_1_1tcp__client_html_a6d15785b71776cd85426c9634cb446f0"><div class="ttname"><a href="classcpp__redis_1_1network_1_1tcp__client.html#a6d15785b71776cd85426c9634cb446f0">cpp_redis::network::tcp_client::async_write</a></div><div class="ttdeci">void async_write(write_request &amp;request)</div></div>
<div class="ttc" id="classcpp__redis_1_1network_1_1tcp__client__iface_html_a9a7d5942205db8be03da581a848b8ec0"><div class="ttname"><a href="classcpp__redis_1_1network_1_1tcp__client__iface.html#a9a7d5942205db8be03da581a848b8ec0">cpp_redis::network::tcp_client_iface::disconnection_handler_t</a></div><div class="ttdeci">std::function&lt; void()&gt; disconnection_handler_t</div><div class="ttdef"><b>Definition:</b> tcp_client_iface.hpp:160</div></div>
<div class="ttc" id="classcpp__redis_1_1network_1_1tcp__client_html_a5808c0569980d83479f755ac55a12dfb"><div class="ttname"><a href="classcpp__redis_1_1network_1_1tcp__client.html#a5808c0569980d83479f755ac55a12dfb">cpp_redis::network::tcp_client::connect</a></div><div class="ttdeci">void connect(const std::string &amp;addr, std::uint32_t port, std::uint32_t timeout_msecs)</div></div>
<div class="ttc" id="classcpp__redis_1_1network_1_1tcp__client__iface_html"><div class="ttname"><a href="classcpp__redis_1_1network_1_1tcp__client__iface.html">cpp_redis::network::tcp_client_iface</a></div><div class="ttdef"><b>Definition:</b> tcp_client_iface.hpp:37</div></div>
<div class="ttc" id="structcpp__redis_1_1network_1_1tcp__client__iface_1_1write__request_html"><div class="ttname"><a href="structcpp__redis_1_1network_1_1tcp__client__iface_1_1write__request.html">cpp_redis::network::tcp_client_iface::write_request</a></div><div class="ttdef"><b>Definition:</b> tcp_client_iface.hpp:129</div></div>
<div class="ttc" id="classcpp__redis_1_1network_1_1tcp__client_html_aa56fc49540d67c5c05b3dda3aaff8a0f"><div class="ttname"><a href="classcpp__redis_1_1network_1_1tcp__client.html#aa56fc49540d67c5c05b3dda3aaff8a0f">cpp_redis::network::tcp_client::set_nb_workers</a></div><div class="ttdeci">void set_nb_workers(std::size_t nb_threads)</div></div>
<div class="ttc" id="classcpp__redis_1_1network_1_1tcp__client_html_a8cbad07ca636e9d60dafc0e5cac8106d"><div class="ttname"><a href="classcpp__redis_1_1network_1_1tcp__client.html#a8cbad07ca636e9d60dafc0e5cac8106d">cpp_redis::network::tcp_client::tcp_client</a></div><div class="ttdeci">tcp_client(void)=default</div><div class="ttdoc">ctor </div></div>
<div class="ttc" id="classcpp__redis_1_1network_1_1tcp__client_html"><div class="ttname"><a href="classcpp__redis_1_1network_1_1tcp__client.html">cpp_redis::network::tcp_client</a></div><div class="ttdef"><b>Definition:</b> tcp_client.hpp:37</div></div>
<div class="ttc" id="namespacecpp__redis_html"><div class="ttname"><a href="namespacecpp__redis.html">cpp_redis</a></div><div class="ttdef"><b>Definition:</b> array_builder.hpp:29</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.13
</small></address>
</body>
</html>
